package com.kly.smartbi.constant;

import com.kly.smartbi.model.dto.user.UserDto;

/**
 * @author admin
 * @date 2025/3/29
 */
public class UserContext {

    /**
     * 用户上下文
     */
    private static final ThreadLocal<UserDto> USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 保存用户
     * @param userDto
     */
    public static void saveUser(UserDto userDto) {
        USER_THREAD_LOCAL.set(userDto);
    }

    /**
     * 获取用户
     * @return
     */
    public static UserDto getUser() {
        return USER_THREAD_LOCAL.get();
    }

    /**
     * 移除用户
     */
    public static void removeUser() {
        USER_THREAD_LOCAL.remove();
    }

}
